package com.open.ssm.converter;

import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.property.ExcelContentProperty;

public class PayStatusConverter implements Converter<String> {

	@Override
	public Class supportJavaTypeKey() {
		return String.class;
	}

	@Override
	public CellDataTypeEnum supportExcelTypeKey() {
		return CellDataTypeEnum.STRING;
	}

	@Override
	public String convertToJavaData(CellData cellData, ExcelContentProperty contentProperty,
			GlobalConfiguration globalConfiguration) throws Exception {
		String str = "";
		String value = cellData.getStringValue();
		switch(value) {
			case "未支付":
				str = "01";
				break;
			case "已取消":
				str = "02";
				break;
			case "已支付":
				str = "99";
				break;
		}
		return str;
	}

	@Override
	public CellData convertToExcelData(String value, ExcelContentProperty contentProperty,
			GlobalConfiguration globalConfiguration) throws Exception {
		String str = "";
		switch(value) {
			case "01":
				str = "未支付";
				break;
			case "02":
				str = "已取消";
				break;
			case "99":
				str = "已支付";
				break;
		}
		return new CellData(str);
	}

}
